# Importing necessary libraries
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import plotly.express as px
import plotly.graph_objects as go
pd.set_option('display.max_columns', None)
# Loading data
df = pd.read_csv("D:/Softwares/DS/Project/FootballData/PL 2019-2020/Premier_league_19_20.csv")
# Viewing top 5 records
df.head()
| date | home_team | away_team | home_score | away_score | home_possession_% | away_possession_% | home_shots_on_target | away_shots_on_target | home_shots | away_shots | home_touches | away_touches | home_passes | away_passes | home_tackles | away_tackles | home_clearances | away_clearances | home_corners | away_corners | home_offsides | away_offsides | home_yellow_cards | away_yellow_cards | home_red_cards | away_red_cards | home_fouls_conceded | away_fouls_conceded | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 08/09/2019 | Liverpool | Norwich City | 4 | 1 | 57.9 | 42.1 | 7.0 | 5.0 | 15.0 | 12.0 | 662.0 | 577.0 | 477.0 | 363.0 | 21.0 | 12.0 | 5.0 | 35.0 | 11.0 | 2.0 | 0.0 | 5.0 | 0.0 | 2.0 | 0.0 | 0.0 | 9.0 | 9.0 |
| 1 | 08/10/2019 | AFC Bournemouth | Sheffield United | 1 | 1 | 52.9 | 47.1 | 3.0 | 3.0 | 13.0 | 8.0 | 671.0 | 615.0 | 485.0 | 428.0 | 18.0 | 14.0 | 13.0 | 16.0 | 3.0 | 4.0 | 1.0 | 1.0 | 2.0 | 1.0 | 0.0 | 0.0 | 10.0 | 19.0 |
| 2 | 08/10/2019 | Burnley | Southampton | 3 | 0 | 46.5 | 53.5 | 4.0 | 3.0 | 10.0 | 11.0 | 549.0 | 579.0 | 332.0 | 393.0 | 21.0 | 7.0 | 13.0 | 18.0 | 2.0 | 7.0 | 5.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 6.0 | 12.0 |
| 3 | 08/10/2019 | Crystal Palace | Everton | 0 | 0 | 35.4 | 64.6 | 2.0 | 3.0 | 6.0 | 10.0 | 467.0 | 722.0 | 268.0 | 500.0 | 21.0 | 14.0 | 21.0 | 18.0 | 6.0 | 2.0 | 4.0 | 0.0 | 2.0 | 1.0 | 0.0 | 1.0 | 16.0 | 14.0 |
| 4 | 08/11/2019 | Leicester City | Wolverhampton Wanderers | 0 | 0 | 70.0 | 30.0 | 1.0 | 2.0 | 16.0 | 8.0 | 871.0 | 508.0 | 665.0 | 291.0 | 20.0 | 19.0 | 12.0 | 33.0 | 12.0 | 3.0 | 0.0 | 1.0 | 0.0 | 2.0 | 0.0 | 0.0 | 3.0 | 13.0 |
# Getting columns names
df.columns
Index(['date', 'home_team', 'away_team', 'home_score', 'away_score',
'home_possession_%', 'away_possession_%', 'home_shots_on_target',
'away_shots_on_target', 'home_shots', 'away_shots', 'home_touches',
'away_touches', 'home_passes', 'away_passes', 'home_tackles',
'away_tackles', 'home_clearances', 'away_clearances', 'home_corners',
'away_corners', 'home_offsides', 'away_offsides', 'home_yellow_cards',
'away_yellow_cards', 'home_red_cards', 'away_red_cards',
'home_fouls_conceded', 'away_fouls_conceded'],
dtype='object')
# Basic info of data
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 380 entries, 0 to 379 Data columns (total 29 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 date 380 non-null object 1 home_team 380 non-null object 2 away_team 380 non-null object 3 home_score 380 non-null int64 4 away_score 380 non-null int64 5 home_possession_% 380 non-null float64 6 away_possession_% 380 non-null float64 7 home_shots_on_target 380 non-null float64 8 away_shots_on_target 380 non-null float64 9 home_shots 380 non-null float64 10 away_shots 380 non-null float64 11 home_touches 380 non-null float64 12 away_touches 380 non-null float64 13 home_passes 380 non-null float64 14 away_passes 380 non-null float64 15 home_tackles 380 non-null float64 16 away_tackles 380 non-null float64 17 home_clearances 380 non-null float64 18 away_clearances 380 non-null float64 19 home_corners 380 non-null float64 20 away_corners 380 non-null float64 21 home_offsides 380 non-null float64 22 away_offsides 380 non-null float64 23 home_yellow_cards 380 non-null float64 24 away_yellow_cards 380 non-null float64 25 home_red_cards 380 non-null float64 26 away_red_cards 380 non-null float64 27 home_fouls_conceded 380 non-null float64 28 away_fouls_conceded 380 non-null float64 dtypes: float64(24), int64(2), object(3) memory usage: 86.2+ KB
# Statistical summary
df.describe()
# (Here it can be seen that min value for each row is 0 which can't be true, might be few missing value in the data or any
# other issue)
| home_score | away_score | home_possession_% | away_possession_% | home_shots_on_target | away_shots_on_target | home_shots | away_shots | home_touches | away_touches | home_passes | away_passes | home_tackles | away_tackles | home_clearances | away_clearances | home_corners | away_corners | home_offsides | away_offsides | home_yellow_cards | away_yellow_cards | home_red_cards | away_red_cards | home_fouls_conceded | away_fouls_conceded | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 | 380.000000 |
| mean | 1.515789 | 1.205263 | 49.922105 | 48.762105 | 4.510526 | 3.989474 | 13.134211 | 11.297368 | 649.642105 | 639.007895 | 455.515789 | 447.452632 | 16.028947 | 16.142105 | 18.021053 | 21.202632 | 5.692105 | 4.842105 | 1.771053 | 1.600000 | 1.565789 | 1.750000 | 0.063158 | 0.063158 | 10.289474 | 10.805263 |
| std | 1.248646 | 1.200252 | 13.970951 | 13.916075 | 2.589281 | 2.509064 | 5.618513 | 5.355292 | 153.601267 | 155.063958 | 145.188885 | 145.111386 | 5.479316 | 5.489815 | 8.982221 | 10.197702 | 3.266919 | 2.853746 | 1.517776 | 1.452139 | 1.249121 | 1.246896 | 0.254170 | 0.243567 | 3.750165 | 3.870458 |
| min | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| 25% | 1.000000 | 0.000000 | 41.400000 | 38.725000 | 3.000000 | 2.000000 | 9.000000 | 7.000000 | 552.000000 | 536.500000 | 358.750000 | 341.000000 | 13.000000 | 13.000000 | 12.000000 | 14.000000 | 3.000000 | 3.000000 | 1.000000 | 0.000000 | 1.000000 | 1.000000 | 0.000000 | 0.000000 | 8.000000 | 8.000000 |
| 50% | 1.000000 | 1.000000 | 49.300000 | 49.850000 | 4.000000 | 4.000000 | 13.000000 | 11.000000 | 638.500000 | 636.500000 | 442.500000 | 441.500000 | 16.000000 | 16.000000 | 17.000000 | 20.000000 | 5.000000 | 5.000000 | 1.000000 | 1.000000 | 1.000000 | 2.000000 | 0.000000 | 0.000000 | 10.000000 | 11.000000 |
| 75% | 2.000000 | 2.000000 | 60.725000 | 58.050000 | 6.000000 | 5.000000 | 16.000000 | 14.250000 | 747.250000 | 729.250000 | 542.250000 | 525.000000 | 20.000000 | 19.250000 | 23.000000 | 27.000000 | 8.000000 | 7.000000 | 3.000000 | 2.000000 | 2.000000 | 3.000000 | 0.000000 | 0.000000 | 13.000000 | 13.000000 |
| max | 8.000000 | 9.000000 | 80.200000 | 76.900000 | 13.000000 | 15.000000 | 31.000000 | 26.000000 | 1109.000000 | 1037.000000 | 969.000000 | 877.000000 | 36.000000 | 34.000000 | 57.000000 | 76.000000 | 17.000000 | 16.000000 | 9.000000 | 8.000000 | 6.000000 | 6.000000 | 2.000000 | 1.000000 | 23.000000 | 24.000000 |
# Checking for missing value
df.isnull().sum()
# No missing value in the data
# (Will have to look other way round to check why min value for each col is 0 in statistical summary)
date 0 home_team 0 away_team 0 home_score 0 away_score 0 home_possession_% 0 away_possession_% 0 home_shots_on_target 0 away_shots_on_target 0 home_shots 0 away_shots 0 home_touches 0 away_touches 0 home_passes 0 away_passes 0 home_tackles 0 away_tackles 0 home_clearances 0 away_clearances 0 home_corners 0 away_corners 0 home_offsides 0 away_offsides 0 home_yellow_cards 0 away_yellow_cards 0 home_red_cards 0 away_red_cards 0 home_fouls_conceded 0 away_fouls_conceded 0 dtype: int64
# Checking for 'home_possession_%' column because almost other stats like home_score, away_score, home_shots_on_target etc
# can be 0 but stats like away_possession_%, home_possession_%, home_passes can't be 0
df[df['home_possession_%'] == 0]
# (Baaamm!! So here is the issue in the data. Stats of few matches are missing so they are recorded as 0 and hence min value
# for each column in statistical summary is 0)
| date | home_team | away_team | home_score | away_score | home_possession_% | away_possession_% | home_shots_on_target | away_shots_on_target | home_shots | away_shots | home_touches | away_touches | home_passes | away_passes | home_tackles | away_tackles | home_clearances | away_clearances | home_corners | away_corners | home_offsides | away_offsides | home_yellow_cards | away_yellow_cards | home_red_cards | away_red_cards | home_fouls_conceded | away_fouls_conceded | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 17 | 08/18/2019 | Sheffield United | Crystal Palace | 1 | 0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 155 | 12/08/2019 | Newcastle United | Southampton | 2 | 1 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 322 | 07/04/2020 | Leicester City | Crystal Palace | 3 | 0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 352 | 07/14/2020 | Chelsea | Norwich City | 1 | 0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 360 | 07/21/2020 | Aston Villa | Arsenal | 1 | 0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
# Removing all the above records which were recorded as 0
df1 = df[~(df['home_possession_%'] == 0)]
df1[df1['home_possession_%'] == 0]
# Successfully removed
| date | home_team | away_team | home_score | away_score | home_possession_% | away_possession_% | home_shots_on_target | away_shots_on_target | home_shots | away_shots | home_touches | away_touches | home_passes | away_passes | home_tackles | away_tackles | home_clearances | away_clearances | home_corners | away_corners | home_offsides | away_offsides | home_yellow_cards | away_yellow_cards | home_red_cards | away_red_cards | home_fouls_conceded | away_fouls_conceded |
|---|
df1.describe()
# Got rid of all the 0's of minimum count for each columns
| home_score | away_score | home_possession_% | away_possession_% | home_shots_on_target | away_shots_on_target | home_shots | away_shots | home_touches | away_touches | home_passes | away_passes | home_tackles | away_tackles | home_clearances | away_clearances | home_corners | away_corners | home_offsides | away_offsides | home_yellow_cards | away_yellow_cards | home_red_cards | away_red_cards | home_fouls_conceded | away_fouls_conceded | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.00000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.000000 | 375.00000 | 375.000000 | 375.000000 |
| mean | 1.514667 | 1.218667 | 50.587733 | 49.412267 | 4.570667 | 4.042667 | 13.309333 | 11.448000 | 658.304000 | 647.528000 | 461.589333 | 453.418667 | 16.242667 | 16.357333 | 18.261333 | 21.485333 | 5.76800 | 4.906667 | 1.794667 | 1.621333 | 1.586667 | 1.773333 | 0.064000 | 0.06400 | 10.426667 | 10.949333 |
| std | 1.253518 | 1.201680 | 12.807587 | 12.807587 | 2.553114 | 2.482730 | 5.445431 | 5.228147 | 134.875357 | 137.238945 | 136.200768 | 136.478880 | 5.190725 | 5.197212 | 8.795415 | 9.964599 | 3.22126 | 2.816934 | 1.513919 | 1.449903 | 1.244166 | 1.238566 | 0.255757 | 0.24508 | 3.580149 | 3.687686 |
| min | 0.000000 | 0.000000 | 23.100000 | 19.800000 | 0.000000 | 0.000000 | 2.000000 | 1.000000 | 408.000000 | 391.000000 | 226.000000 | 190.000000 | 5.000000 | 5.000000 | 1.000000 | 3.000000 | 0.00000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.00000 | 0.000000 | 1.000000 |
| 25% | 1.000000 | 0.000000 | 41.750000 | 39.100000 | 3.000000 | 2.000000 | 10.000000 | 8.000000 | 556.000000 | 539.500000 | 362.000000 | 348.000000 | 13.000000 | 13.000000 | 12.000000 | 14.000000 | 3.00000 | 3.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 0.000000 | 0.00000 | 8.000000 | 8.000000 |
| 50% | 1.000000 | 1.000000 | 49.900000 | 50.100000 | 4.000000 | 4.000000 | 13.000000 | 11.000000 | 642.000000 | 639.000000 | 443.000000 | 443.000000 | 16.000000 | 16.000000 | 17.000000 | 20.000000 | 5.00000 | 5.000000 | 1.000000 | 1.000000 | 1.000000 | 2.000000 | 0.000000 | 0.00000 | 10.000000 | 11.000000 |
| 75% | 2.000000 | 2.000000 | 60.900000 | 58.250000 | 6.000000 | 5.000000 | 16.000000 | 15.000000 | 748.500000 | 730.500000 | 544.000000 | 528.000000 | 20.000000 | 20.000000 | 23.000000 | 27.000000 | 8.00000 | 7.000000 | 3.000000 | 2.000000 | 2.000000 | 3.000000 | 0.000000 | 0.00000 | 13.000000 | 13.000000 |
| max | 8.000000 | 9.000000 | 80.200000 | 76.900000 | 13.000000 | 15.000000 | 31.000000 | 26.000000 | 1109.000000 | 1037.000000 | 969.000000 | 877.000000 | 36.000000 | 34.000000 | 57.000000 | 76.000000 | 17.00000 | 16.000000 | 9.000000 | 8.000000 | 6.000000 | 6.000000 | 2.000000 | 1.00000 | 23.000000 | 24.000000 |
# Getting only home and away matches played by Liverpool
Liverpool_19_20_matches = df1[(df1['home_team'] == 'Liverpool') | (df1['away_team'] == 'Liverpool')]
Liverpool_19_20_matches.head(3)
# (Here it can be seen that the data has no record of which team won or lost)
| date | home_team | away_team | home_score | away_score | home_possession_% | away_possession_% | home_shots_on_target | away_shots_on_target | home_shots | away_shots | home_touches | away_touches | home_passes | away_passes | home_tackles | away_tackles | home_clearances | away_clearances | home_corners | away_corners | home_offsides | away_offsides | home_yellow_cards | away_yellow_cards | home_red_cards | away_red_cards | home_fouls_conceded | away_fouls_conceded | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 08/09/2019 | Liverpool | Norwich City | 4 | 1 | 57.9 | 42.1 | 7.0 | 5.0 | 15.0 | 12.0 | 662.0 | 577.0 | 477.0 | 363.0 | 21.0 | 12.0 | 5.0 | 35.0 | 11.0 | 2.0 | 0.0 | 5.0 | 0.0 | 2.0 | 0.0 | 0.0 | 9.0 | 9.0 |
| 18 | 08/17/2019 | Southampton | Liverpool | 1 | 2 | 36.2 | 63.8 | 3.0 | 6.0 | 14.0 | 15.0 | 497.0 | 735.0 | 296.0 | 530.0 | 15.0 | 7.0 | 27.0 | 30.0 | 5.0 | 9.0 | 4.0 | 1.0 | 2.0 | 1.0 | 0.0 | 0.0 | 10.0 | 6.0 |
| 23 | 08/24/2019 | Liverpool | Arsenal | 3 | 1 | 52.0 | 48.0 | 5.0 | 3.0 | 25.0 | 9.0 | 747.0 | 738.0 | 553.0 | 516.0 | 25.0 | 16.0 | 11.0 | 27.0 | 6.0 | 4.0 | 1.0 | 4.0 | 1.0 | 1.0 | 0.0 | 0.0 | 8.0 | 5.0 |
# Creating conditions to apply on Liverpool_19_20_matches to get new column informing Won, Lost or Draw
conditions = [
(Liverpool_19_20_matches['home_score'] > Liverpool_19_20_matches['away_score']) & (Liverpool_19_20_matches['home_team'] == 'Liverpool'),
(Liverpool_19_20_matches['away_score'] > Liverpool_19_20_matches['home_score']) & (Liverpool_19_20_matches['away_team'] == 'Liverpool'),
(Liverpool_19_20_matches['home_score'] == Liverpool_19_20_matches['away_score']),
(Liverpool_19_20_matches['home_score'] < Liverpool_19_20_matches['away_score']) & (Liverpool_19_20_matches['home_team'] == 'Liverpool'),
(Liverpool_19_20_matches['away_score'] < Liverpool_19_20_matches['home_score']) & (Liverpool_19_20_matches['away_team'] == 'Liverpool')
]
# Create a list of the values we want to assign for each condition
values = ['Liverpool Won', 'Liverpool Won', 'Draw', 'Liverpool Lost', 'Liverpool Lost']
# Create a new column and use np.select to assign values to it using our lists as arguments
Liverpool_19_20_matches['match_result'] = np.select(conditions, values)
C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:3: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy This is separate from the ipykernel package so we can avoid doing imports until
# Viewing top 2 records to check if the new column got added to the dataframe or not
Liverpool_19_20_matches.head(2)
| date | home_team | away_team | home_score | away_score | home_possession_% | away_possession_% | home_shots_on_target | away_shots_on_target | home_shots | away_shots | home_touches | away_touches | home_passes | away_passes | home_tackles | away_tackles | home_clearances | away_clearances | home_corners | away_corners | home_offsides | away_offsides | home_yellow_cards | away_yellow_cards | home_red_cards | away_red_cards | home_fouls_conceded | away_fouls_conceded | match_result | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 08/09/2019 | Liverpool | Norwich City | 4 | 1 | 57.9 | 42.1 | 7.0 | 5.0 | 15.0 | 12.0 | 662.0 | 577.0 | 477.0 | 363.0 | 21.0 | 12.0 | 5.0 | 35.0 | 11.0 | 2.0 | 0.0 | 5.0 | 0.0 | 2.0 | 0.0 | 0.0 | 9.0 | 9.0 | Liverpool Won |
| 18 | 08/17/2019 | Southampton | Liverpool | 1 | 2 | 36.2 | 63.8 | 3.0 | 6.0 | 14.0 | 15.0 | 497.0 | 735.0 | 296.0 | 530.0 | 15.0 | 7.0 | 27.0 | 30.0 | 5.0 | 9.0 | 4.0 | 1.0 | 2.0 | 1.0 | 0.0 | 0.0 | 10.0 | 6.0 | Liverpool Won |
# Grouping few columns to check whether or not the logic applied using np.select holds true for the matches
Liverpool_19_20_matches.groupby(['home_team', 'home_score', 'away_team', 'away_score', 'match_result']).size().reset_index()
| home_team | home_score | away_team | away_score | match_result | 0 | |
|---|---|---|---|---|---|---|
| 0 | AFC Bournemouth | 0 | Liverpool | 3 | Liverpool Won | 1 |
| 1 | Arsenal | 2 | Liverpool | 1 | Liverpool Lost | 1 |
| 2 | Aston Villa | 1 | Liverpool | 2 | Liverpool Won | 1 |
| 3 | Brighton and Hove Albion | 1 | Liverpool | 3 | Liverpool Won | 1 |
| 4 | Burnley | 0 | Liverpool | 3 | Liverpool Won | 1 |
| 5 | Chelsea | 1 | Liverpool | 2 | Liverpool Won | 1 |
| 6 | Crystal Palace | 1 | Liverpool | 2 | Liverpool Won | 1 |
| 7 | Everton | 0 | Liverpool | 0 | Draw | 1 |
| 8 | Leicester City | 0 | Liverpool | 4 | Liverpool Won | 1 |
| 9 | Liverpool | 1 | Burnley | 1 | Draw | 1 |
| 10 | Liverpool | 1 | Wolverhampton Wanderers | 0 | Liverpool Won | 1 |
| 11 | Liverpool | 2 | AFC Bournemouth | 1 | Liverpool Won | 1 |
| 12 | Liverpool | 2 | Aston Villa | 0 | Liverpool Won | 1 |
| 13 | Liverpool | 2 | Brighton and Hove Albion | 1 | Liverpool Won | 1 |
| 14 | Liverpool | 2 | Leicester City | 1 | Liverpool Won | 1 |
| 15 | Liverpool | 2 | Manchester United | 0 | Liverpool Won | 1 |
| 16 | Liverpool | 2 | Sheffield United | 0 | Liverpool Won | 1 |
| 17 | Liverpool | 2 | Tottenham Hotspur | 1 | Liverpool Won | 1 |
| 18 | Liverpool | 2 | Watford | 0 | Liverpool Won | 1 |
| 19 | Liverpool | 3 | Arsenal | 1 | Liverpool Won | 1 |
| 20 | Liverpool | 3 | Manchester City | 1 | Liverpool Won | 1 |
| 21 | Liverpool | 3 | Newcastle United | 1 | Liverpool Won | 1 |
| 22 | Liverpool | 3 | West Ham United | 2 | Liverpool Won | 1 |
| 23 | Liverpool | 4 | Crystal Palace | 0 | Liverpool Won | 1 |
| 24 | Liverpool | 4 | Norwich City | 1 | Liverpool Won | 1 |
| 25 | Liverpool | 4 | Southampton | 0 | Liverpool Won | 1 |
| 26 | Liverpool | 5 | Chelsea | 3 | Liverpool Won | 1 |
| 27 | Liverpool | 5 | Everton | 2 | Liverpool Won | 1 |
| 28 | Manchester City | 4 | Liverpool | 0 | Liverpool Lost | 1 |
| 29 | Manchester United | 1 | Liverpool | 1 | Draw | 1 |
| 30 | Newcastle United | 1 | Liverpool | 3 | Liverpool Won | 1 |
| 31 | Norwich City | 0 | Liverpool | 1 | Liverpool Won | 1 |
| 32 | Sheffield United | 0 | Liverpool | 1 | Liverpool Won | 1 |
| 33 | Southampton | 1 | Liverpool | 2 | Liverpool Won | 1 |
| 34 | Tottenham Hotspur | 0 | Liverpool | 1 | Liverpool Won | 1 |
| 35 | Watford | 3 | Liverpool | 0 | Liverpool Lost | 1 |
| 36 | West Ham United | 0 | Liverpool | 2 | Liverpool Won | 1 |
| 37 | Wolverhampton Wanderers | 1 | Liverpool | 2 | Liverpool Won | 1 |
Liverpool_home = Liverpool_19_20_matches[(Liverpool_19_20_matches['home_team'] == 'Liverpool')]
Liverpool_home
| date | home_team | away_team | home_score | away_score | home_possession_% | away_possession_% | home_shots_on_target | away_shots_on_target | home_shots | away_shots | home_touches | away_touches | home_passes | away_passes | home_tackles | away_tackles | home_clearances | away_clearances | home_corners | away_corners | home_offsides | away_offsides | home_yellow_cards | away_yellow_cards | home_red_cards | away_red_cards | home_fouls_conceded | away_fouls_conceded | match_result | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 08/09/2019 | Liverpool | Norwich City | 4 | 1 | 57.9 | 42.1 | 7.0 | 5.0 | 15.0 | 12.0 | 662.0 | 577.0 | 477.0 | 363.0 | 21.0 | 12.0 | 5.0 | 35.0 | 11.0 | 2.0 | 0.0 | 5.0 | 0.0 | 2.0 | 0.0 | 0.0 | 9.0 | 9.0 | Liverpool Won |
| 23 | 08/24/2019 | Liverpool | Arsenal | 3 | 1 | 52.0 | 48.0 | 5.0 | 3.0 | 25.0 | 9.0 | 747.0 | 738.0 | 553.0 | 516.0 | 25.0 | 16.0 | 11.0 | 27.0 | 6.0 | 4.0 | 1.0 | 4.0 | 1.0 | 1.0 | 0.0 | 0.0 | 8.0 | 5.0 | Liverpool Won |
| 43 | 09/14/2019 | Liverpool | Newcastle United | 3 | 1 | 75.3 | 24.7 | 9.0 | 1.0 | 21.0 | 8.0 | 1023.0 | 470.0 | 847.0 | 282.0 | 13.0 | 20.0 | 8.0 | 33.0 | 10.0 | 1.0 | 2.0 | 8.0 | 0.0 | 0.0 | 0.0 | 0.0 | 5.0 | 4.0 | Liverpool Won |
| 73 | 10/05/2019 | Liverpool | Leicester City | 2 | 1 | 50.7 | 49.3 | 8.0 | 1.0 | 18.0 | 2.0 | 733.0 | 681.0 | 494.0 | 478.0 | 19.0 | 16.0 | 25.0 | 27.0 | 4.0 | 6.0 | 3.0 | 2.0 | 1.0 | 4.0 | 0.0 | 0.0 | 9.0 | 17.0 | Liverpool Won |
| 93 | 10/27/2019 | Liverpool | Tottenham Hotspur | 2 | 1 | 68.0 | 32.0 | 13.0 | 4.0 | 21.0 | 11.0 | 836.0 | 523.0 | 631.0 | 298.0 | 20.0 | 16.0 | 8.0 | 35.0 | 8.0 | 3.0 | 0.0 | 4.0 | 3.0 | 3.0 | 0.0 | 0.0 | 9.0 | 11.0 | Liverpool Won |
| 113 | 11/10/2019 | Liverpool | Manchester City | 3 | 1 | 45.0 | 55.0 | 5.0 | 3.0 | 12.0 | 18.0 | 609.0 | 717.0 | 416.0 | 507.0 | 13.0 | 15.0 | 27.0 | 24.0 | 4.0 | 13.0 | 3.0 | 5.0 | 0.0 | 2.0 | 0.0 | 0.0 | 10.0 | 5.0 | Liverpool Won |
| 133 | 11/30/2019 | Liverpool | Brighton and Hove Albion | 2 | 1 | 44.8 | 55.2 | 7.0 | 5.0 | 15.0 | 12.0 | 654.0 | 790.0 | 482.0 | 592.0 | 11.0 | 11.0 | 16.0 | 20.0 | 4.0 | 5.0 | 1.0 | 6.0 | 0.0 | 0.0 | 1.0 | 0.0 | 3.0 | 10.0 | Liverpool Won |
| 148 | 12/04/2019 | Liverpool | Everton | 5 | 2 | 58.5 | 41.5 | 5.0 | 4.0 | 11.0 | 12.0 | 704.0 | 542.0 | 501.0 | 339.0 | 15.0 | 19.0 | 25.0 | 15.0 | 5.0 | 6.0 | 3.0 | 3.0 | 1.0 | 2.0 | 0.0 | 0.0 | 13.0 | 17.0 | Liverpool Won |
| 165 | 12/14/2019 | Liverpool | Watford | 2 | 0 | 67.9 | 32.1 | 6.0 | 2.0 | 16.0 | 8.0 | 847.0 | 514.0 | 649.0 | 309.0 | 14.0 | 21.0 | 14.0 | 35.0 | 6.0 | 3.0 | 5.0 | 4.0 | 2.0 | 1.0 | 0.0 | 0.0 | 8.0 | 6.0 | Liverpool Won |
| 193 | 12/29/2019 | Liverpool | Wolverhampton Wanderers | 1 | 0 | 62.9 | 37.1 | 3.0 | 2.0 | 10.0 | 10.0 | 808.0 | 559.0 | 607.0 | 352.0 | 19.0 | 23.0 | 15.0 | 20.0 | 5.0 | 6.0 | 2.0 | 5.0 | 1.0 | 0.0 | 0.0 | 0.0 | 7.0 | 3.0 | Liverpool Won |
| 203 | 01/02/2020 | Liverpool | Sheffield United | 2 | 0 | 74.8 | 25.2 | 7.0 | 2.0 | 19.0 | 3.0 | 1109.0 | 470.0 | 969.0 | 327.0 | 6.0 | 14.0 | 9.0 | 29.0 | 8.0 | 4.0 | 1.0 | 3.0 | 0.0 | 0.0 | 0.0 | 0.0 | 5.0 | 8.0 | Liverpool Won |
| 223 | 01/19/2020 | Liverpool | Manchester United | 2 | 0 | 53.2 | 46.8 | 5.0 | 4.0 | 16.0 | 9.0 | 717.0 | 659.0 | 509.0 | 455.0 | 22.0 | 16.0 | 13.0 | 34.0 | 11.0 | 5.0 | 2.0 | 3.0 | 1.0 | 3.0 | 0.0 | 0.0 | 7.0 | 10.0 | Liverpool Won |
| 244 | 02/01/2020 | Liverpool | Southampton | 4 | 0 | 61.5 | 38.5 | 9.0 | 4.0 | 16.0 | 17.0 | 728.0 | 539.0 | 530.0 | 321.0 | 14.0 | 18.0 | 23.0 | 26.0 | 6.0 | 11.0 | 2.0 | 5.0 | 0.0 | 2.0 | 0.0 | 0.0 | 9.0 | 15.0 | Liverpool Won |
| 265 | 02/24/2020 | Liverpool | West Ham United | 3 | 2 | 69.3 | 30.7 | 7.0 | 4.0 | 25.0 | 7.0 | 861.0 | 495.0 | 626.0 | 269.0 | 23.0 | 19.0 | 19.0 | 43.0 | 16.0 | 8.0 | 2.0 | 2.0 | 0.0 | 3.0 | 0.0 | 0.0 | 4.0 | 10.0 | Liverpool Won |
| 285 | 03/07/2020 | Liverpool | AFC Bournemouth | 2 | 1 | 74.5 | 25.5 | 6.0 | 4.0 | 14.0 | 6.0 | 917.0 | 419.0 | 729.0 | 246.0 | 7.0 | 9.0 | 20.0 | 43.0 | 9.0 | 4.0 | 1.0 | 5.0 | 0.0 | 1.0 | 0.0 | 0.0 | 10.0 | 12.0 | Liverpool Won |
| 303 | 06/24/2020 | Liverpool | Crystal Palace | 4 | 0 | 73.3 | 26.7 | 7.0 | 0.0 | 21.0 | 3.0 | 1051.0 | 509.0 | 886.0 | 330.0 | 17.0 | 20.0 | 1.0 | 37.0 | 6.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 7.0 | 5.0 | Liverpool Won |
| 323 | 07/05/2020 | Liverpool | Aston Villa | 2 | 0 | 71.2 | 28.8 | 4.0 | 3.0 | 6.0 | 9.0 | 830.0 | 457.0 | 672.0 | 263.0 | 7.0 | 8.0 | 18.0 | 26.0 | 7.0 | 5.0 | 1.0 | 5.0 | 1.0 | 1.0 | 0.0 | 0.0 | 18.0 | 8.0 | Liverpool Won |
| 343 | 07/11/2020 | Liverpool | Burnley | 1 | 1 | 70.8 | 29.2 | 9.0 | 2.0 | 23.0 | 6.0 | 857.0 | 436.0 | 659.0 | 265.0 | 10.0 | 11.0 | 17.0 | 36.0 | 11.0 | 6.0 | 2.0 | 3.0 | 1.0 | 2.0 | 0.0 | 0.0 | 7.0 | 4.0 | Draw |
| 363 | 07/22/2020 | Liverpool | Chelsea | 5 | 3 | 50.0 | 50.0 | 7.0 | 5.0 | 10.0 | 10.0 | 749.0 | 752.0 | 584.0 | 575.0 | 19.0 | 9.0 | 14.0 | 15.0 | 6.0 | 0.0 | 0.0 | 3.0 | 1.0 | 0.0 | 0.0 | 0.0 | 8.0 | 11.0 | Liverpool Won |
Liverpool_home['home_score'].sum()
# Liverpool scored 52 goals at their home, against all the teams.
52
Liverpool_home['away_score'].sum()
# Liverpool only conceded 16 goals at their home
16
Liverpool_home['home_possession_%'].mean()
# Liverpool had the possession of 63% at Home in the overall 2019-2020 season.
62.18947368421052
Liverpool_home['away_possession_%'].mean()
# Liverpool's apponent managed to keep only 38% possession at Liverpool's Home.
37.81052631578948
Liverpool_home['home_shots'].sum()
# Liverpool had 314 shots while playing at Home
314.0
Liverpool_home['home_shots_on_target'].sum()
# Out of 314 total shots, Liverpool shooted 129 shots on target.
129.0
Liverpool_home['away_shots'].sum()
# Liverpools opponent were allowed 172 shots at Anfield.
172.0
Liverpool_home['away_shots_on_target'].sum()
# Out of 172 total shots, opponent managed only to shoot 58 shots on target.
58.0
Liverpool_home['home_passes'].sum()
# Liverpool passed 11821 no. of passes throughout 19-20 season.
11821.0
Liverpool_home['away_passes'].sum()
# Liverpool's opponent managed 7087 no. of passes when playing against Liverpool at Anfiled.
7087.0
Liverpool_home['home_tackles'].sum()
# Liverpool tackled 295 times at home.
295.0
Liverpool_home['away_tackles'].sum()
# Opponent teams tackled 293 times on Liverpool players.
293.0
Liverpool_home['home_clearances'].sum()
# No. of clearances made by Liverpool are 288
288.0
Liverpool_home['away_clearances'].sum()
# No. of clearances made by opponent teams are 560. These are high because of the no. of shots
560.0
Liverpool_home['home_corners'].sum()
# Liverpool got 143 corners
143.0
Liverpool_home['away_corners'].sum()
# Whereas oppponent teams got 92 corners
92.0
Liverpool_home['home_offsides'].sum()
# Liverpool were 31 times offside at home.
31.0
Liverpool_home['away_offsides'].sum()
# Opponent team were 76 times offside.
76.0
Liverpool_home['home_yellow_cards'].sum()
# 13 yellow cards were given to Liverpool players for making foul.
13.0
Liverpool_home['away_yellow_cards'].sum()
# 27 yellow cards were given to opponent teams for making foul.
27.0
Liverpool_home['home_red_cards'].sum()
# Liverpool player got 1 red card for causing a severe foul.
1.0
Liverpool_home['away_red_cards'].sum()
# Opponent teams player didn't recieve a single red card while playing against Liverpool at Anfield.
0.0
Liverpool_home['home_fouls_conceded'].sum()
# Total no. of fouls conceded by Livepool are 156 out of which 13 Yellow cards and 1 Red card was given.
156.0
Liverpool_home['away_fouls_conceded'].sum()
# Total no. of fouls conceded by opponent teams are 170 out of which 27 were given as Yellow cards.
170.0
Liverpool_away = Liverpool_19_20_matches[(Liverpool_19_20_matches['away_team'] == 'Liverpool')]
Liverpool_away
| date | home_team | away_team | home_score | away_score | home_possession_% | away_possession_% | home_shots_on_target | away_shots_on_target | home_shots | away_shots | home_touches | away_touches | home_passes | away_passes | home_tackles | away_tackles | home_clearances | away_clearances | home_corners | away_corners | home_offsides | away_offsides | home_yellow_cards | away_yellow_cards | home_red_cards | away_red_cards | home_fouls_conceded | away_fouls_conceded | match_result | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 18 | 08/17/2019 | Southampton | Liverpool | 1 | 2 | 36.2 | 63.8 | 3.0 | 6.0 | 14.0 | 15.0 | 497.0 | 735.0 | 296.0 | 530.0 | 15.0 | 7.0 | 27.0 | 30.0 | 5.0 | 9.0 | 4.0 | 1.0 | 2.0 | 1.0 | 0.0 | 0.0 | 10.0 | 6.0 | Liverpool Won |
| 31 | 08/31/2019 | Burnley | Liverpool | 0 | 3 | 36.2 | 63.8 | 2.0 | 7.0 | 7.0 | 15.0 | 495.0 | 739.0 | 318.0 | 568.0 | 14.0 | 11.0 | 21.0 | 19.0 | 6.0 | 4.0 | 5.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 10.0 | 16.0 | Liverpool Won |
| 52 | 09/22/2019 | Chelsea | Liverpool | 1 | 2 | 55.0 | 45.0 | 2.0 | 3.0 | 13.0 | 6.0 | 713.0 | 608.0 | 492.0 | 415.0 | 15.0 | 11.0 | 10.0 | 37.0 | 6.0 | 4.0 | 7.0 | 1.0 | 3.0 | 3.0 | 0.0 | 0.0 | 8.0 | 13.0 | Liverpool Won |
| 67 | 09/28/2019 | Sheffield United | Liverpool | 0 | 1 | 29.6 | 70.4 | 2.0 | 4.0 | 12.0 | 16.0 | 479.0 | 896.0 | 291.0 | 708.0 | 11.0 | 11.0 | 29.0 | 25.0 | 6.0 | 5.0 | 0.0 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 8.0 | 4.0 | Liverpool Won |
| 86 | 10/20/2019 | Manchester United | Liverpool | 1 | 1 | 32.0 | 68.0 | 2.0 | 4.0 | 7.0 | 10.0 | 509.0 | 842.0 | 299.0 | 652.0 | 10.0 | 18.0 | 29.0 | 17.0 | 3.0 | 1.0 | 4.0 | 1.0 | 0.0 | 1.0 | 0.0 | 0.0 | 6.0 | 14.0 | Draw |
| 101 | 11/02/2019 | Aston Villa | Liverpool | 1 | 2 | 26.3 | 73.7 | 2.0 | 6.0 | 4.0 | 25.0 | 447.0 | 860.0 | 226.0 | 634.0 | 20.0 | 17.0 | 47.0 | 21.0 | 2.0 | 10.0 | 3.0 | 2.0 | 1.0 | 2.0 | 0.0 | 0.0 | 12.0 | 9.0 | Liverpool Won |
| 124 | 11/23/2019 | Crystal Palace | Liverpool | 1 | 2 | 40.0 | 60.0 | 6.0 | 4.0 | 16.0 | 12.0 | 544.0 | 703.0 | 330.0 | 510.0 | 14.0 | 24.0 | 31.0 | 29.0 | 9.0 | 8.0 | 3.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 | 8.0 | 7.0 | Liverpool Won |
| 151 | 12/07/2019 | AFC Bournemouth | Liverpool | 0 | 3 | 26.2 | 73.8 | 0.0 | 9.0 | 3.0 | 21.0 | 467.0 | 1017.0 | 305.0 | 852.0 | 12.0 | 10.0 | 35.0 | 5.0 | 1.0 | 3.0 | 5.0 | 1.0 | 0.0 | 1.0 | 0.0 | 0.0 | 5.0 | 6.0 | Liverpool Won |
| 179 | 01/29/2020 | West Ham United | Liverpool | 0 | 2 | 29.4 | 70.6 | 4.0 | 5.0 | 7.0 | 13.0 | 519.0 | 1007.0 | 331.0 | 828.0 | 17.0 | 17.0 | 19.0 | 12.0 | 3.0 | 7.0 | 1.0 | 0.0 | 2.0 | 0.0 | 0.0 | 0.0 | 6.0 | 6.0 | Liverpool Won |
| 185 | 12/26/2019 | Leicester City | Liverpool | 0 | 4 | 41.2 | 58.8 | 0.0 | 6.0 | 3.0 | 15.0 | 618.0 | 788.0 | 421.0 | 590.0 | 16.0 | 10.0 | 36.0 | 15.0 | 2.0 | 8.0 | 6.0 | 3.0 | 1.0 | 1.0 | 0.0 | 0.0 | 5.0 | 7.0 | Liverpool Won |
| 218 | 01/11/2020 | Tottenham Hotspur | Liverpool | 0 | 1 | 33.2 | 66.8 | 4.0 | 7.0 | 14.0 | 13.0 | 591.0 | 961.0 | 381.0 | 786.0 | 13.0 | 20.0 | 38.0 | 9.0 | 4.0 | 3.0 | 2.0 | 2.0 | 0.0 | 2.0 | 0.0 | 0.0 | 4.0 | 8.0 | Liverpool Won |
| 236 | 01/23/2020 | Wolverhampton Wanderers | Liverpool | 1 | 2 | 46.4 | 53.6 | 3.0 | 6.0 | 10.0 | 13.0 | 678.0 | 755.0 | 505.0 | 594.0 | 11.0 | 11.0 | 7.0 | 20.0 | 2.0 | 4.0 | 2.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 | 6.0 | 11.0 | Liverpool Won |
| 256 | 02/15/2020 | Norwich City | Liverpool | 0 | 1 | 36.7 | 63.3 | 1.0 | 6.0 | 5.0 | 17.0 | 571.0 | 801.0 | 373.0 | 624.0 | 17.0 | 16.0 | 33.0 | 7.0 | 2.0 | 7.0 | 1.0 | 0.0 | 1.0 | 2.0 | 0.0 | 0.0 | 5.0 | 11.0 | Liverpool Won |
| 278 | 02/29/2020 | Watford | Liverpool | 3 | 0 | 29.2 | 70.8 | 5.0 | 1.0 | 14.0 | 7.0 | 485.0 | 893.0 | 299.0 | 732.0 | 13.0 | 8.0 | 41.0 | 13.0 | 3.0 | 5.0 | 5.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 4.0 | 8.0 | Liverpool Lost |
| 293 | 06/21/2020 | Everton | Liverpool | 0 | 0 | 29.9 | 70.1 | 3.0 | 3.0 | 8.0 | 10.0 | 426.0 | 767.0 | 256.0 | 594.0 | 20.0 | 16.0 | 26.0 | 3.0 | 1.0 | 6.0 | 2.0 | 1.0 | 2.0 | 2.0 | 0.0 | 0.0 | 15.0 | 12.0 | Draw |
| 316 | 07/02/2020 | Manchester City | Liverpool | 4 | 0 | 47.0 | 53.0 | 6.0 | 3.0 | 14.0 | 11.0 | 662.0 | 709.0 | 490.0 | 551.0 | 10.0 | 13.0 | 19.0 | 8.0 | 3.0 | 3.0 | 3.0 | 2.0 | 2.0 | 2.0 | 0.0 | 0.0 | 8.0 | 7.0 | Liverpool Lost |
| 333 | 07/08/2020 | Brighton and Hove Albion | Liverpool | 1 | 3 | 44.4 | 55.6 | 2.0 | 8.0 | 12.0 | 20.0 | 594.0 | 667.0 | 381.0 | 477.0 | 12.0 | 11.0 | 39.0 | 18.0 | 6.0 | 10.0 | 5.0 | 0.0 | 1.0 | 4.0 | 0.0 | 0.0 | 7.0 | 15.0 | Liverpool Won |
| 350 | 07/15/2020 | Arsenal | Liverpool | 2 | 1 | 31.1 | 68.9 | 2.0 | 8.0 | 3.0 | 24.0 | 456.0 | 816.0 | 286.0 | 614.0 | 21.0 | 12.0 | 24.0 | 3.0 | 2.0 | 13.0 | 5.0 | 4.0 | 3.0 | 1.0 | 0.0 | 0.0 | 14.0 | 10.0 | Liverpool Lost |
| 377 | 07/26/2020 | Newcastle United | Liverpool | 1 | 3 | 25.3 | 74.7 | 2.0 | 6.0 | 3.0 | 14.0 | 428.0 | 981.0 | 267.0 | 792.0 | 23.0 | 12.0 | 23.0 | 8.0 | 2.0 | 4.0 | 3.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 11.0 | 5.0 | Liverpool Won |
Liverpool_away['away_score'].sum()
# Liverpool scored 33 goals while playing away (NOT at their home)
33
Liverpool_away['home_score'].sum()
# Liverpool conceded 17 goals while playing away
17
Liverpool_away['away_possession_%'].mean()
# Liverpool hold the ball 65% while playing away.
64.4578947368421
Liverpool_away['home_possession_%'].mean()
# Opponent teams had the possession of 36%.
35.542105263157886
Liverpool_away['away_shots'].sum()
# Liverpool's total no. of shots at away stadiums are 277.
277.0
Liverpool_away['away_shots_on_target'].sum()
# Liverpool's total no. of shots on target at away are 102.
102.0
Liverpool_away['home_shots'].sum()
# Opponent teams managed to shoot total of 169 shots.
169.0
Liverpool_away['home_shots_on_target'].sum()
# Opponent teams total no. of shots on target are 51
51.0
Liverpool_away['away_passes'].sum()
# Total no. of ball passed by Liverpool team are 12051.
12051.0
Liverpool_away['home_passes'].sum()
# Total no. of ball passed by opponent team are 6547
6547.0
Liverpool_away['away_tackles'].sum()
# Liverpool tackled 255 times at away
255.0
Liverpool_away['home_tackles'].sum()
# Opponent team tackled 284 times to Liverpool players.
284.0
Liverpool_away['away_clearances'].sum()
# 299 times Liverpool cleared the ball and prevented the opponent team to not score the goal. (prevented to not take the shot)
299.0
Liverpool_away['home_clearances'].sum()
# Opponent teams cleared the ball 534 times and prevented Liverpool to not the score the goal
534.0
Liverpool_away['away_corners'].sum()
# 114 corners were given to Liverpool while playing away.
114.0
Liverpool_away['home_corners'].sum()
# Opponent teams got 68 corners while playing against Liverpool.
68.0
Liverpool_away['away_offsides'].sum()
# Total no. of offsides that were done by Liverpool are 22.
22.0
Liverpool_away['home_offsides'].sum()
# Opponent teams were 66 times offside while playing against Liverpool.
66.0
Liverpool_away['away_yellow_cards'].sum()
# Total no. of yellow cards that were shown to Liverpool in the season 19-20 are 25.
25.0
Liverpool_away['home_yellow_cards'].sum()
# Opponent team were given 20 yellow cards.
20.0
Liverpool_away['away_red_cards'].sum()
# Liverpool got no red card while playing away.
0.0
Liverpool_away['home_red_cards'].sum()
# Even opponent got no red card.
0.0
Liverpool_away['away_fouls_conceded'].sum()
# Total no. of fouls done by Liverpool are 175 out of which 25 are yellow cards and 0 red card.
175.0
Liverpool_away['home_fouls_conceded'].sum()
# Total no. of fouls committed by opponent's are 152 out of which 20 were given as Yellow card while no red card was given.
152.0
Liverpool_home.head(3)
| date | home_team | away_team | home_score | away_score | home_possession_% | away_possession_% | home_shots_on_target | away_shots_on_target | home_shots | away_shots | home_touches | away_touches | home_passes | away_passes | home_tackles | away_tackles | home_clearances | away_clearances | home_corners | away_corners | home_offsides | away_offsides | home_yellow_cards | away_yellow_cards | home_red_cards | away_red_cards | home_fouls_conceded | away_fouls_conceded | match_result | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 08/09/2019 | Liverpool | Norwich City | 4 | 1 | 57.9 | 42.1 | 7.0 | 5.0 | 15.0 | 12.0 | 662.0 | 577.0 | 477.0 | 363.0 | 21.0 | 12.0 | 5.0 | 35.0 | 11.0 | 2.0 | 0.0 | 5.0 | 0.0 | 2.0 | 0.0 | 0.0 | 9.0 | 9.0 | Liverpool Won |
| 23 | 08/24/2019 | Liverpool | Arsenal | 3 | 1 | 52.0 | 48.0 | 5.0 | 3.0 | 25.0 | 9.0 | 747.0 | 738.0 | 553.0 | 516.0 | 25.0 | 16.0 | 11.0 | 27.0 | 6.0 | 4.0 | 1.0 | 4.0 | 1.0 | 1.0 | 0.0 | 0.0 | 8.0 | 5.0 | Liverpool Won |
| 43 | 09/14/2019 | Liverpool | Newcastle United | 3 | 1 | 75.3 | 24.7 | 9.0 | 1.0 | 21.0 | 8.0 | 1023.0 | 470.0 | 847.0 | 282.0 | 13.0 | 20.0 | 8.0 | 33.0 | 10.0 | 1.0 | 2.0 | 8.0 | 0.0 | 0.0 | 0.0 | 0.0 | 5.0 | 4.0 | Liverpool Won |
# Bar plot to see the no. of goals Liverpool scored against each team while playing at Home in 19-20 season.
sns.set(rc = {'figure.figsize':(10,5)})
sns.set(style="darkgrid", color_codes=True)
sns.barplot(x='home_score', y='away_team', data=Liverpool_home, palette="ch:s=.25", edgecolor='pink')
plt.title('Goals Scored By Liverpool when playing at Anfield - ')
plt.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most no. of goals scored by Liverpool is 5, against two teams : Everton and Chelsea
# Followed by 4 goals against three teams : Norwich City, Southampton and Crystal Palace
# Followed by 3 goals against four teams : Arsenal, Newcastle United, Manchester City and West Ham United
# Least no. of goals scored by Liverpool is 1, against two teams : Wolves and Burnley
# Majority of times Liverpool scored 2 goals against the opponent team
# Key-Point : Their is not a single team against which Liverpool has scored 0 goal while playing at Home.
# Plotting bar plot to see the no. of goals Opponent team scored against Liverpool while playing at Home in 19-20 season.
sns.set(rc = {'figure.figsize':(10,5)})
sns.set(style="darkgrid", color_codes=True)
sns.barplot(x='away_score', y='away_team', data=Liverpool_home, palette="crest", edgecolor='skyblue')
plt.title('Goals Scored By Opponent Team when playing at Anfield- ')
plt.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Chelsea scored most no. of goals against Liverpool : 3 goals
# Followed by 2 goals against Liverpool : Everton and West Ham United
# Majority of teams managed to score only 1 goal against Liverpool at Home.
# Key-Point : Most of the teams could not score even single goal against Liverpool.
# Scatter plot to see the ball possession by Liverpool against each team while playing at Home in 19-20 season.
fig = px.scatter(Liverpool_home, x="home_possession_%", y="away_team", color='away_team', size='home_possession_%',
title = "Liverpool's Possession against each team -")
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most possession(70-75%) Liverpool has against teams : Newcastle United, Sheffield United, AFC Bournemouth, Crystal Palace, Aston Villa, Burnely
# Least Possession(44-50%) Liverpool has against teams : Man City, Brighton and Chelsea
# Key Point : Man City, Brighton and Chelsea has more possession when playing against Liverpool at Home in 19-20 season.
# Even after having more possession than Liverpool above all 3 teams lost the match at Liverpool's Home.
# Bar plot to see the Home Shots and Home Shots On Target by Liverpool against each team while playing at Home in 19-20 season.
fig = px.bar(Liverpool_home, y="away_team", x=["home_shots", "home_shots_on_target"], barmode='group',
title='Total Home Shots and Shots On Target by Liverpool against each team -')
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most no. of Shots(25) Liverpool has are against West Ham United and Arsenal followed by Burnley(23), Crystal Palace(21), Tottenham(21) and Newscastle United(21)
# Most no. of Shots On Target are against Tottenham(13), Burnley(9), Southampton(9) and Newscastle United(9)
# Least no. of Shots are against Aston Villa(6) followed by Chelsea(10) and Wolves(10)
# Least no. of Shots On Target are against Wolves(3), Aston Villa(4), Manchester United(5) and Arsenal(5)
# Key-Point : Despite having least no. of shots(10) and least no. of shots on target(7) against Chelsea, Liverpool scored 5 goals against them.
# Bar plot to see the Away Shots and Away shots on target by Opponent team on Liverpool while playing at Home in 19-20 season.
fig = px.bar(Liverpool_home, y="away_team", x=["away_shots", "away_shots_on_target"], barmode='group',
title='Total Away Shots and Shots On Target by all teams against Liverpool -',
color_discrete_sequence=px.colors.qualitative.T10_r)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most no. of Shots against Liverpool are by Man City(18) followed by Southampton(17), Everton(12), Brighton(12) and Norwich City(12)
# Most no. of Shots On Target against Liverpool are by Chelsea(5), Brighton(5) and Norwich City(5)
# Least no. of Shots against Liverpool are by Leicester City(2) followed by Crystal Palace(3) and Sheffield United(3)
# Least no. of Shots On Target against Liverpool are by Crystal Palace(0) followed by Leicester City(1) and Newcastle United(1)
# Key-Point : Despite having only 1 Shot On Target, both Leicester City and Newcastle United managed to score 1 goal against Liverpool but could not win or drew the match.
# Bar plot to see the Home Passes(made by Liverpool team) and Away Passes(made by opponent team) while playing at Liverpool's Home in 19-20 season.
fig = px.bar(Liverpool_home, y="away_team", x=["home_passes", "away_passes"], barmode='group',
title="Home Passes and Away Passes at Liverpool's Home -",
color_discrete_sequence=px.colors.qualitative.Dark24_r)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most passes Liverpool made were against Sheffield United(969) followed by Crystal Palace(886) and Newcastle United(847)
# Least passes Liverpool made were against Man City(416), Brighton(482) then Everton(501) and Manchester United(509)
# Most passes made by opponent team against Liverpool are 592 made by Brighton followed by Chelsea(575)
# Least passes made by opponent team against Liverpool are 246 made by AFC Bournemouth followed by Aston Villa(263) and Burnley(265)
# Dumbble Chart to compare Home Tackles vs Away Tackles
Liverpool_home.reset_index(drop=True, inplace=True)
fig = go.Figure()
fig.add_trace(go.Scatter(x = Liverpool_home["home_tackles"],
y = Liverpool_home["away_team"],
mode = 'markers',
marker_color = 'red',
marker_size = 12,
name = 'Home Tackles'))
fig.add_trace(go.Scatter(x = Liverpool_home["away_tackles"],
y = Liverpool_home["away_team"],
mode = 'markers',
marker_color = 'grey',
marker_size = 10,
name = 'Away Tackles'))
for i in range(0, len(Liverpool_home)):
fig.add_shape(type='line',
x0 = Liverpool_home["home_tackles"][i],
y0 = i,
x1 = Liverpool_home["away_tackles"][i],
y1 = i,
line=dict(color='brown', width = 2))
fig.update_layout(title_text =
"Home Tackles vs Away Tackles -"
)
#fig.update_xaxes(range=[300, 1200])
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most Home Tackles(made by Liverpool) were against Arsenal(25) followed by West Ham United(23) then Manchester United(22)
# Least Home Tackles(made by Liverpool) were against Sheffield United(6) followed by Aston Villa and AFC Bournemouth (7)
# Most Away Tackles(made by Opponent) were by teams Wolves(23) followed by Watford(21) then Crystal Palace and Newcastle United (20)
# Least Away Tackles(made by Opponent) were by teams Aston Villa(8) followed by AFC Bournemouth(9) and Chelsea(9)
# Key-Point : Brighton and Liverpool made same number of tackles.
# Dumbble Chart to compare Home Clearances vs Away Clearances
fig = go.Figure()
fig.add_trace(go.Scatter(x = Liverpool_home["home_clearances"],
y = Liverpool_home["away_team"],
mode = 'markers',
marker_color = 'red',
marker_size = 12,
name = 'Home Clearances'))
fig.add_trace(go.Scatter(x = Liverpool_home["away_clearances"],
y = Liverpool_home["away_team"],
mode = 'markers',
marker_color = 'orange',
marker_size = 10,
name = 'Away Clearances'))
for i in range(0, len(Liverpool_home)):
fig.add_shape(type='line',
x0 = Liverpool_home["home_clearances"][i],
y0 = i,
x1 = Liverpool_home["away_clearances"][i],
y1 = i,
line=dict(color='skyblue', width = 2))
fig.update_layout(title_text =
"Home Clearances vs Away Clearances -"
)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most Home Clearances(made by Liverpool) were against Manchester City(27) followed by Leicester City(25) and Everton(25)
# Least Home Clearances(made by Liverpool) were against Crystal Palace(1) followed by Norwich City(5) then Tottenham Hotspur(8) and Newcastle United(8)
# Most Away Clearances(made by Opponent) were by teams AFC Bournemouth(43) and West Ham United(43) followed by Crystal Palace(37) and Burnley(36)
# Least Away Clearances(made by Opponent) were by teams Chelsea(15) and Everton(15) followed by Brighton(20) and Wolves(20)
# Key-Point : Manchester City was the most threatening team in attack whereas Crystal Palace was least threatening while playing at Liverpool's home.
# AFC Bournemouth and West Ham United were good in defence as they cleared the most no. chances to score whereas Chelsea and Everton were average in thier defence.
# Dumbble Chart to compare Home Corners vs Away Corners
fig = go.Figure()
fig.add_trace(go.Scatter(x = Liverpool_home["home_corners"],
y = Liverpool_home["away_team"],
mode = 'markers',
marker_color = 'red',
marker_size = 12,
name = 'Home Corners'))
fig.add_trace(go.Scatter(x = Liverpool_home["away_corners"],
y = Liverpool_home["away_team"],
mode = 'markers',
marker_color = 'black',
marker_size = 10,
name = 'Away Corners'))
for i in range(0, len(Liverpool_home)):
fig.add_shape(type='line',
x0 = Liverpool_home["home_corners"][i],
y0 = i,
x1 = Liverpool_home["away_corners"][i],
y1 = i,
line=dict(color='grey', width = 2))
fig.update_layout(title_text =
"Home Corners vs Away Corners -"
)
#fig.update_xaxes(range=[300, 1200])
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most Home Corners(made by Liverpool) were against West Ham United(16) followed by Burnley(11), Manchester United(11) and Norwich City(11)
# Least Home Corners(made by Liverpool) were against Brighton(4), Manchester City(4) and Leicester City(4) followed by Wolves(5) and Everton(5)
# Most Away Corners(made by Opponent) were by teams Manchester City(13) followed by Sounthampton(11)
# Least Away Corners(made by Opponent) were by teams Chelsea(0) and Crystal Palace(0) followed by Newcastle United(1) and Norwich City(2)
# Bar Plot to see the Home Fouls Conceded(including Yellow and Red Card) and Away Fouls Conceded(including Yellow and Red Card)
fig = px.bar(Liverpool_home, y="away_team", x=["home_fouls_conceded", "home_red_cards", "home_yellow_cards",
"away_fouls_conceded", "away_red_cards", "away_yellow_cards"],
barmode='stack',
title="Home Fouls Conceded vs Away Fouls Conceded (including Yellow and Red card) at Liverpool's Home -",
color_discrete_sequence=px.colors.qualitative.G10_r)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most Home Foul are conceded against Aston Villa(18) followed by Everton(13)
# Least Home Foul are conceded against Brighton(3) followed by West Ham United(4)
# Most Yellow Card Liverpool players got were against Tottenham(3) followed by Watford(2)
# Liverpool player got 0 Yellow Card against Crystal Palace, AFC Bournemouth, West Ham United, Southampton, Sheffield United, Brighton, Manhester City, Newcastle United and Norwich City
# Liverpool player got 1 Red Card against Brighton
# Most Away Fouls(Opponent team) were done by Everton(17) and Leicester City(17) followed by Southampton(15)
# Least Away Fouls(Opponent team) were done by Wolves(3) followed by Burnley(4) amd Newcastle United(4)
# Away Team which conceded Most Yellow Card are Leicester City(4) followed by West Ham United(3),Manchester United(3) and Tottenham(3)
# Least Yellow Card(0) conceded by Away Teams are Chelsea, Crystal Palace, Sheffield United, Wolves, Brighton and Newcastle United
# Away team got no red card(0) while playing against Liverpool at Liverpool's Home.
# Key-Points : Following are the matches with NO Yellow Card and Red Card -
# LFC vs Crystal Palace , LFC vs Sheffield United , LFC vs Newcastle United
# Pie plot to see the match result when Liverpool played at Home
print('List of Teams Liverpool won against -\n\n', Liverpool_home.groupby(['away_team','match_result']).size().reset_index().rename(columns={0:'Count'}))
print('-'*70)
print('\nNo. of matches Liverpool Won/Lost or Drawn -\n', Liverpool_home['match_result'].value_counts())
print('-'*70)
fig = px.pie(Liverpool_home, names='match_result' ,
color='match_result' ,
color_discrete_map={'Liverpool Won':'lightgreen',
'Draw':'orange',
'Liverpool Lost':'lightcyan'} ,
title='Match Result when Liverpool played at Home -')
fig.update_layout(
autosize=False,
width=550,
height=400
)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Out of total 19 matches played at Liverpool's Home, Liverpool won 94.7% of matches i.e, 18 matches.
# Liverpool drew only 1 match out of all 19 ,against Burnley.
# Key-Point : Liverpool has not lost a single match when played at Anfield in 2019-2020 season.
List of Teams Liverpool won against -
away_team match_result Count
0 AFC Bournemouth Liverpool Won 1
1 Arsenal Liverpool Won 1
2 Aston Villa Liverpool Won 1
3 Brighton and Hove Albion Liverpool Won 1
4 Burnley Draw 1
5 Chelsea Liverpool Won 1
6 Crystal Palace Liverpool Won 1
7 Everton Liverpool Won 1
8 Leicester City Liverpool Won 1
9 Manchester City Liverpool Won 1
10 Manchester United Liverpool Won 1
11 Newcastle United Liverpool Won 1
12 Norwich City Liverpool Won 1
13 Sheffield United Liverpool Won 1
14 Southampton Liverpool Won 1
15 Tottenham Hotspur Liverpool Won 1
16 Watford Liverpool Won 1
17 West Ham United Liverpool Won 1
18 Wolverhampton Wanderers Liverpool Won 1
----------------------------------------------------------------------
No. of matches Liverpool Won/Lost or Drawn -
Liverpool Won 18
Draw 1
Name: match_result, dtype: int64
----------------------------------------------------------------------
Liverpool_away.head(3)
| date | home_team | away_team | home_score | away_score | home_possession_% | away_possession_% | home_shots_on_target | away_shots_on_target | home_shots | away_shots | home_touches | away_touches | home_passes | away_passes | home_tackles | away_tackles | home_clearances | away_clearances | home_corners | away_corners | home_offsides | away_offsides | home_yellow_cards | away_yellow_cards | home_red_cards | away_red_cards | home_fouls_conceded | away_fouls_conceded | match_result | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 18 | 08/17/2019 | Southampton | Liverpool | 1 | 2 | 36.2 | 63.8 | 3.0 | 6.0 | 14.0 | 15.0 | 497.0 | 735.0 | 296.0 | 530.0 | 15.0 | 7.0 | 27.0 | 30.0 | 5.0 | 9.0 | 4.0 | 1.0 | 2.0 | 1.0 | 0.0 | 0.0 | 10.0 | 6.0 | Liverpool Won |
| 31 | 08/31/2019 | Burnley | Liverpool | 0 | 3 | 36.2 | 63.8 | 2.0 | 7.0 | 7.0 | 15.0 | 495.0 | 739.0 | 318.0 | 568.0 | 14.0 | 11.0 | 21.0 | 19.0 | 6.0 | 4.0 | 5.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 10.0 | 16.0 | Liverpool Won |
| 52 | 09/22/2019 | Chelsea | Liverpool | 1 | 2 | 55.0 | 45.0 | 2.0 | 3.0 | 13.0 | 6.0 | 713.0 | 608.0 | 492.0 | 415.0 | 15.0 | 11.0 | 10.0 | 37.0 | 6.0 | 4.0 | 7.0 | 1.0 | 3.0 | 3.0 | 0.0 | 0.0 | 8.0 | 13.0 | Liverpool Won |
# Bar plot to see the no. of goals Liverpool scored against each team while playing Away in 19-20 season.
sns.set(rc = {'figure.figsize':(10,5)})
sns.set(style="darkgrid", color_codes=True)
sns.barplot(x='away_score', y='home_team', data=Liverpool_away, palette="rocket", edgecolor='red')
plt.title('Goals Scored By Liverpool(Away) - ')
plt.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most no. of goals by Liverpool is 4 which was scored against Leicester City.
# Followed by 3 goals against four teams : Burnley, AFC Bournemouth, Brighton and Newcastle United.
# Majority of the times Liverpool scored 2 goals against the opponent team.
# Key-Point : Liverpool scored 0 goal against Watford, Everton and Manchester City while playing at their respective home.
# Bar plot to see the no. of goals Opponent team scored against Liverpool while playing Away in 19-20 season.
sns.set(rc = {'figure.figsize':(10,5)})
sns.set(style="darkgrid", color_codes=True)
sns.barplot(x='home_score', y='home_team', data=Liverpool_away, palette="mako", edgecolor='blue')
plt.title('Goals Scored By Opponent while playing at their respective Home - ')
plt.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Manchester City scored most no. of goals against Liverpool : 4 goals , followed by Watford : 3 goals
# Majority of teams managed to score 1 goal against Liverpool at their respective Home.
# Key-Point : Most of the teams could not score even single goal against Liverpool.
# Scatter plot to see the ball possession by Liverpool against each team while playing at Home in 19-20 season.
fig = px.scatter(Liverpool_away, x="away_possession_%", y="home_team", color='home_team', size='away_possession_%',
title = "Liverpool's Possession against each team when playing Away -")
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most possession(70-75%) Liverpool has against teams : Newcastle United, Sheffield United, AFC Bournemouth, West Ham United, Aston Villa, Watford and Everton
# Least Possession(44-50%) Liverpool has against teams : Chelsea
# Key Point : Chelsea, Man City and Wolves has more possession when playing against Liverpool at thier respective Home in 19-20 season.
# Bar plot to see the Away Shots and Away Shots On Target by Liverpool against each team while playing Away in 19-20 season.
fig = px.bar(Liverpool_away, y="home_team", x=["away_shots", "away_shots_on_target"], barmode='group',
title='Total Home Shots and Shots On Target against each team by Liverpool(Away) -',
color_discrete_sequence=px.colors.qualitative.Bold_r)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most no. of Shots(25) Liverpool has are against Aston Villa(25) followed by Arsenal(24) then AFC Bournemouth(21) and further Brighton(20)
# Most no. of Shots On Target are against AFC Bournemouth(9) followed by Arsenal(8) and Brighton(8) then Tottenham(7) at their respective Home
# Least no. of Shots are against Chelsea(6) followed by Watford(7), Everton(10) and Manchester City(11)
# Least no. of Shots On Target are against Watford(1) followed by Chelsea(3), Everton(3) and Manchester City(3)
# Key-Point : Out of all the games where Liverpool had both Least Shots and Least Shots on Target, they managed to win only 1 game(against Chlesea), Drawn(against Everton) rest all Lost.
# Bar plot to see the Home Shots and Home shots on target by Opponent team against Liverpool while playing Away in 19-20 season.
fig = px.bar(Liverpool_away, y="home_team", x=["home_shots", "home_shots_on_target"], barmode='group',
title='Total Away Shots and Shots On Target by all teams against Liverpool(Away) -',
color_discrete_sequence=px.colors.qualitative.Antique_r)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most no. of Shots against Liverpool are by Crystal Palace(16) followed by Manchester City(14), Watford(14), Tottenham(14) and Southampton(14).
# Most no. of Shots On Target against Liverpool are by Crystal Palace(6) and Manchester City(6) followed by Watford(5) then Tottenham(4).
# Least no. of Shots against Liverpool are by Newcastle United(3), Arsenal(3), Leicester City(3) and AFC Bournemouth(3)
# Least no. of Shots On Target against Liverpool are by Norwich City(1) and most of the teams managed to only have 2 shots on target while playing at their respective Home, those teams are Newcastle United, Arsenal, Brighton, Aston Villa, Manchester United, Sheffield United, Chelsea and Burnley.
# Key-Point : Leicester City and AFC Bournemouth had 0 shots on target.
# Despite having most no. of both Shot and Shot On Target, Crystal Palace could not win the match.
# Bar plot to see the Away Passes(made by Liverpool team) and Home Passes(made by opponent team) while playing Liverpool(Away) in 19-20 season.
fig = px.bar(Liverpool_away, y="home_team", x=["home_passes","away_passes"], barmode='group',
title="Home Passes and Away Passes at Opponent Teams respective Home -",
color_discrete_sequence=px.colors.qualitative.Set2)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most passes Liverpool made were against AFC Bournemouth(852) followed by West Ham United(828), Newcastle United(792) and Tottenham(786).
# Least passes Liverpool made were against Chelsea(415) followed by Brighton(477) and Crystal Palace(510).
# Most passes made by opponent team against Liverpool are 505 made by Wolves followed by Chelsea(492) and Manchester City(490).
# Least passes made by opponent team against Liverpool are 226 made by Aston Villa(226) followed by Everton(256) and Newcastle United(267).
# Dumbble Chart to compare Away Tackles(of Liverpool) vs Home Tackles
Liverpool_away.reset_index(drop=True, inplace=True)
fig = go.Figure()
fig.add_trace(go.Scatter(x = Liverpool_away["away_tackles"],
y = Liverpool_away["home_team"],
mode = 'markers',
marker_color = 'red',
marker_size = 12,
name = 'Away Tackles'))
fig.add_trace(go.Scatter(x = Liverpool_away["home_tackles"],
y = Liverpool_away["home_team"],
mode = 'markers',
marker_color = 'green',
marker_size = 10,
name = 'Home Tackles'))
for i in range(0, len(Liverpool_home)):
fig.add_shape(type='line',
x0 = Liverpool_away["away_tackles"][i],
y0 = i,
x1 = Liverpool_away["home_tackles"][i],
y1 = i,
line=dict(color='silver', width = 2))
fig.update_layout(title_text =
"Away Tackles vs Home Tackles -"
)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most Away Tackles(made by Liverpool) were against Crystal Palace(24) followed by Tottenham(20) then Manchester United(18).
# Least Away Tackles(made by Liverpool) were against Southampton(7) followed by Watford(8) then AFC Bournemouth(10) and Leicester City(10).
# Most Home Tackles(made by Opponent) were by teams Newcastle United(23) followed by Arsenal(21) then Everton(20) and Aston Villa(20).
# Least Home Tackles(made by Opponent) were by teams Manchester City(10) and Manchester United(10).
# Key-Point : Thier were 3 games which ended with same no. of home and away tackles - Wolves vs Liverpool , West Ham United vs Liverpool and Sheffield United vs Liverpool.
# Dumbble Chart to compare Away Clearances vs Home Clearances
fig = go.Figure()
fig.add_trace(go.Scatter(x = Liverpool_away["away_clearances"],
y = Liverpool_away["home_team"],
mode = 'markers',
marker_color = 'red',
marker_size = 12,
name = 'Away Clearances'))
fig.add_trace(go.Scatter(x = Liverpool_away["home_clearances"],
y = Liverpool_away["home_team"],
mode = 'markers',
marker_color = 'purple',
marker_size = 10,
name = 'Home Clearances'))
for i in range(0, len(Liverpool_away)):
fig.add_shape(type='line',
x0 = Liverpool_away["away_clearances"][i],
y0 = i,
x1 = Liverpool_away["home_clearances"][i],
y1 = i,
line=dict(color='gold', width = 2))
fig.update_layout(title_text =
"Away Clearances vs Home Clearances -"
)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most Away Clearances(made by Liverpool) were against Chelsea(37) followed by Southampton(30) and Crystal Palace(29).
# Least Away Clearances(made by Liverpool) were against Arsenal(3) and Everton(3) followed by AFC Bournemouth(5).
# Most Home Clearances(made by Opponent) were by teams Aston Villa(47) followed by Watford(41) then Brighton(39).
# Least Home Clearances(made by Opponent) were by teams Wolves(7) followed by Chelsea(10) then Manchester City(19) and West Ham United(19).
# Key-Point : Most attacking team against Liverpool was Chelsea at Chelsea's Home.
# Dumbble Chart to compare Away Corners vs Home Corners
fig = go.Figure()
fig.add_trace(go.Scatter(x = Liverpool_away["away_corners"],
y = Liverpool_away["home_team"],
mode = 'markers',
marker_color = 'red',
marker_size = 12,
name = 'Away Corners'))
fig.add_trace(go.Scatter(x = Liverpool_away["home_corners"],
y = Liverpool_away["home_team"],
mode = 'markers',
marker_color = 'maroon',
marker_size = 10,
name = 'Home Corners'))
for i in range(0, len(Liverpool_away)):
fig.add_shape(type='line',
x0 = Liverpool_away["away_corners"][i],
y0 = i,
x1 = Liverpool_away["home_corners"][i],
y1 = i,
line=dict(color='lime', width = 2))
fig.update_layout(title_text =
"Away Corners vs Home Corners -"
)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most Away Corners(made by Liverpool) were against Arsenal(13) followed by Brighton(10) and Aston Villa(10).
# Least Away Corners(made by Liverpool) were against Manchester United(1) followed by Manchester City(3), Tottenham(3) and AFC Bournemouth(3).
# Most Home Corners(made by Opponent) were by teams Crystal Palace(9) followed by Brighton(6), Sheffiled United(6), Chelsea(6) and Burnley(6).
# Least Home Corners(made by Opponent) were by teams Everton(1) and AFC Bournemouth(1).
# Bar Plot to see the Away Fouls Conceded(including Yellow and Red Card) and Home Fouls Conceded(including Yellow and Red Card)
fig = px.bar(Liverpool_away, y="home_team", x=["away_fouls_conceded", "away_red_cards", "away_yellow_cards",
"home_fouls_conceded", "home_red_cards", "home_yellow_cards"],
barmode='stack',
title="Away Fouls vs Home Fouls Conceded (including Yellow and Red card) at Opponent's respective Home -",
color_discrete_sequence=px.colors.qualitative.Set2)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Most Away Foul(made by Liverpool) are conceded against Burnley(16) followed by Brighton(15).
# Least Away Foul are conceded against Sheffield United(4) followed by Newcastle United(5).
# Most Yellow Card Liverpool got were against Brighton(4) followed by Chelsea(3).
# Liverpool got 0 Yellow Card against Newcastle United, Watford, West Ham United and Burnley.
# Most Home Fouls(made by Opponent team) were done by Everton(15) followed by Arsenal(14).
# Least Home Fouls were done by Watford(4), Tottenham(4) followed by Norwich City(5), Leicester City(5) and AFC Bournemouth(5).
# Home Team which conceded Most Yellow Card are Chelsea(3) and Arsenal(3).
# Least Yellow Card(0) conceded by Home team are Watford, Wolves, Tottenham, AFC Bournemout, Crystal Palace, Manchester United and Burnley,
# Key-Points : None of the team, neither Away Team(Liverpool) nor Home Teams got any Red card.
# Matches with NO Yellow Card and Red Card - Watford vs Liverpool , Burnley vs Liverpool.
# Pie plot to see the match result when Liverpool played Away
print('List of Teams Liverpool won against at their respective Home-\n\n', Liverpool_away.groupby(['home_team','match_result']).size().reset_index().rename(columns={0:'Count'}))
print('-'*70)
print('\nNo. of matches Liverpool Won/Lost or Drawn -\n', Liverpool_away['match_result'].value_counts())
print('-'*70)
fig = px.pie(Liverpool_away, names='match_result' ,
color_discrete_sequence=px.colors.sequential.Darkmint,
title='Match Result when Liverpool played Away -')
fig.update_layout(
autosize=False,
width=550,
height=400
)
fig.show()
# ------------------------------------Observation based on the graph---------------------------------------------
# Liverpool Won 14 Away matches out of 19, i.e, they won 73.7% matches.
# Liverpool drew only 2 matches out of all 19 ,against Everton and Manchester United.
# Liverpool Lost 3 Away matches, against Arsenal, Manchester City and Watford. Matches lost = 15.8%
List of Teams Liverpool won against at their respective Home-
home_team match_result Count
0 AFC Bournemouth Liverpool Won 1
1 Arsenal Liverpool Lost 1
2 Aston Villa Liverpool Won 1
3 Brighton and Hove Albion Liverpool Won 1
4 Burnley Liverpool Won 1
5 Chelsea Liverpool Won 1
6 Crystal Palace Liverpool Won 1
7 Everton Draw 1
8 Leicester City Liverpool Won 1
9 Manchester City Liverpool Lost 1
10 Manchester United Draw 1
11 Newcastle United Liverpool Won 1
12 Norwich City Liverpool Won 1
13 Sheffield United Liverpool Won 1
14 Southampton Liverpool Won 1
15 Tottenham Hotspur Liverpool Won 1
16 Watford Liverpool Lost 1
17 West Ham United Liverpool Won 1
18 Wolverhampton Wanderers Liverpool Won 1
----------------------------------------------------------------------
No. of matches Liverpool Won/Lost or Drawn -
Liverpool Won 14
Liverpool Lost 3
Draw 2
Name: match_result, dtype: int64
----------------------------------------------------------------------
fig = px.pie(Liverpool_19_20_matches, names='match_result' ,
color='match_result' ,
color_discrete_map={'Liverpool Won':'mediumturquoise',
'Draw':'grey',
'Liverpool Lost':'gold'} ,
title='Match Result of Liverpool when played Home and Away-')
fig.update_layout(
autosize=False,
width=500,
height=550
)
fig.update_traces(textfont_size=18,
marker=dict(line=dict(color='#000000', width=2)))
fig.show()
# Cumulative total of points throughout the season of Liverpool and team played against Liverpool
Teams = Liverpool_19_20_matches['home_team'].unique()
TeamLists = {Team : [0] for Team in Teams}
for row in Liverpool_19_20_matches.itertuples():
Home = row.home_team
Away = row.away_team
if row.home_score > row.away_score:
TeamLists[Home].append(TeamLists[Home][-1]+3)
TeamLists[Away].append(TeamLists[Away][-1]+0)
elif row.home_score < row.away_score:
TeamLists[Home].append(TeamLists[Home][-1]+0)
TeamLists[Away].append(TeamLists[Away][-1]+3)
else:
TeamLists[Home].append(TeamLists[Home][-1]+1)
TeamLists[Away].append(TeamLists[Away][-1]+1)
# Storing Liverpool points in a variable
Liverpool_points = TeamLists['Liverpool']
Liverpool_points
[0, 3, 6, 9, 12, 15, 18, 21, 24, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 79, 82, 83, 86, 86, 89, 92, 93, 93, 96, 99]
# Deleting 1st variable cause we want the points from 1st match itself
Liverpool_points.pop(0)
Liverpool_points
[3, 6, 9, 12, 15, 18, 21, 24, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 79, 82, 83, 86, 86, 89, 92, 93, 93, 96, 99]
# Creating a list from 1 to 38 as each team plays 38 no. of matches in a season
Matchday = list(range(1,39))
Matchday
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38]
fig = px.line(x=Matchday, y=Liverpool_points, hover_name=Liverpool_19_20_matches['match_result'],
color_discrete_sequence = ['red'])
fig.update_layout(
title={
'text': "Liverpool Points Throughout the Season 2019-2020",
'x':0.5,
'xanchor': 'center',
'yanchor': 'top'},
xaxis_title="Number Of Games -->",
yaxis_title="Points -->",
font=dict(
family="Times New Roman",
size=16,
color="Navy"
)
)
fig['layout']['title']['font'] = dict(size=28)
fig.update_xaxes(title_font_family="Courier New")
fig.update_yaxes(title_font_family="Courier New")
fig.show()